package com.common.jump;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.curry.android.util.IntentHelper;
import com.orangelife.mobile.complaints.activity.ComplainAdviceAddActivity;
import com.orangelife.mobile.complaints.activity.SelectHouseActivity;
import com.orangelife.mobile.login.activity.SelectCityActivity;
import com.orangelife.mobile.login.activity.SelectCommunityActivity;
import com.orangelife.mobile.myhouse.activity.SelectHouseLocationActivity;

/**
 * 选择城市、小区、楼栋、房号
 * <p/>
 * Created by 吴格非 on 2016-9-6.
 * <p/>
 *
 * @author 吴格非
 * @since v3.8.2
 */
public class LocationJumper {

    public static void jumpToSelectCity(Context context) {
        jumpToSelectCity(context, false);
    }

    public static void jumpToSelectCity(Context context, boolean isNeedNewTask) {
        Intent intent = new Intent();
        intent.setClass(context,
                SelectCityActivity.class);
        if (isNeedNewTask) {
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }
        context.startActivity(intent);
        IntentHelper.getInstances().jumpActivityAnimation(context, false);
    }

    /** 跳转到选择小区的界面 */
    public static void jumpToSelectComm(Context context, String city, String longitude, String latitude, boolean isLocation) {
        Intent intent = new Intent(context,
                SelectCommunityActivity.class);
        intent.putExtra("isLocation", isLocation);
        intent.putExtra("longitude", longitude);
        intent.putExtra("latitude", latitude);
        if (isLocation && city != null && !city.contains("市")) {
            city = city + "市";
        }
        intent.putExtra("cityName", city);
        context.startActivity(intent);
        IntentHelper.getInstances().jumpActivityAnimation(context, false);
    }

    /** 投诉建议的选择位置 */
    public static void jumpSelectHouse(int type, String id, Activity activity) {
        Intent intent = new Intent(activity, SelectHouseActivity.class);
        intent.putExtra("selectType", type);
        intent.putExtra("id", id);
        activity.startActivityForResult(intent, ComplainAdviceAddActivity.SELECT_TYPE);
        IntentHelper.getInstances().jumpActivityAnimation(activity, false);
    }

    /** 房屋认证的选择位置 */
    public static void jumpToSelectLocation(Activity context, String type, String preValue) {
        Intent intent = new Intent(context, SelectHouseLocationActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString(SelectHouseLocationActivity.INTENT_SELECT_TYPE, type);
        bundle.putString(SelectHouseLocationActivity.INTENT_PRE_VALUE, preValue);
        intent.putExtras(bundle);
        context.startActivityForResult(intent, 0);
        IntentHelper.getInstances().jumpActivityAnimation(context, false);
    }
}
